<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/20
 * Time: 12:07
 */

namespace app\admin\controller\goods;


use app\admin\controller\BaseController;
use think\Controller;
use app\admin\model\Goods;
use think\Session;
use think\Db;
class Stock extends BaseController
{
    public function page(){
        $goods=new Goods();
        $user=(new Session())->get("user");
        if($user["id"]){
            $items=$goods->with(["user","category"])
                ->where([
                    "is_del"        =>0,
                    "stock"         =>0,
                    "is_push"       =>0,
                    "store_id"      =>$user["id"]
                ])
                ->paginate(15);
        }else{
            $items=$goods->with(["user","category"])
                ->where([
                    "is_del"        =>0,
                    "stock"         =>0,
                    "is_push"       =>0
                ])
                ->paginate(15);
        }

        $page=$items->render();
        $items=$items->getCollection();
        //dump($page);die();
        $this->assign("page",$page);
        $this->assign("items",$items);
        return $this->fetch("goods/index/index");
    }

    public function add(){
        return $this->fetch("goods/index/add");
    }

    public function create(){
        return $this->fetch("goods/index/create");
    }
}